﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DTO;
using BUS;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
using QLDT.Report;


namespace QLDT
{
    public partial class frm_report_BaoCaoSinhVien : DevExpress.XtraEditors.XtraForm
    {
        public frm_report_BaoCaoSinhVien()
        {
            InitializeComponent();
            
        }
        private void LoadThongtin()
        {
         
            cmb_theolop.Items.Add("Tất cả");
            cmb_theolop.SelectedItem = "Tất cả";
            List<DTO_Lop> lop = new List<DTO_Lop>();
            lop = BUS_Lop.SelectLop();
            for (int i = 0; i < lop.Count; i++)
            {
                cmb_theolop.Items.Add(lop[i].Malop);
            }
          


            cmb_khoahoc.Items.Add("Tất cả");
            cmb_khoahoc.SelectedItem = "Tất cả";
            List<DTO_KhoaHoc> khoahoc = new List<DTO_KhoaHoc>();
            khoahoc = BUS_KhoaHoc.SelectKhoaHoc();
            for (int i = 0; i < khoahoc.Count; i++)
            {
                cmb_khoahoc.Items.Add(khoahoc[i].MaKH);
            }
        }
        //SqlConnection conn= new SqlConnection(@"Server=(local);Database=QLDT;Trusted_Connection=True;");
        public void load()
        {
            try
            {
                string malop = cmb_theolop.Text;
                string khoahoc = cmb_khoahoc.Text;
                if (cmb_theolop.Text == "Tất cả")
                {
                    malop = "%";
                }
                if (cmb_khoahoc.Text == "Tất cả")
                {
                    khoahoc = "%";
                }
               
                // DTO_SinhVien SV = new DTO_SinhVien();
                List<DTO_SinhVien> sv = BUS_report.SelectSinhVien_report(malop,khoahoc);
                rpt_BaoCaoSinhVien cr = new rpt_BaoCaoSinhVien();
                cr.SetDataSource(sv);
                report1.ReportSource = cr;
            }
            catch { }
        }
        private void frm_report_BaoCaoSinhVien_Load(object sender, EventArgs e)
        {
            LoadThongtin();
            //load();
        }

        private void cmb_theolop_SelectedIndexChanged(object sender, EventArgs e)
        {
            load();
        }

        private void cmb_khoahoc_SelectedIndexChanged(object sender, EventArgs e)
        {
            load();
        }
    }
}